<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template shared_ptr</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../interprocess/indexes_reference.html#doxygen.boost_interprocess_header_reference.shared__ptr_8hpp" title="Header &lt;boost/interprocess/smart_ptr/shared_ptr.hpp&gt;">
<link rel="prev" href="structboost_1_1interprocess_1_1managed__shared__ptr.html" title="Struct template managed_shared_ptr">
<link rel="next" href="shared__ptr_8hpp_1a946d9135de9f10bec397e4972c3160ac.html" title="Function template make_managed_shared_ptr">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="structboost_1_1interprocess_1_1managed__shared__ptr.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../interprocess/indexes_reference.html#doxygen.boost_interprocess_header_reference.shared__ptr_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="shared__ptr_8hpp_1a946d9135de9f10bec397e4972c3160ac.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template shared_ptr</span></h2>
<p>boost::interprocess::shared_ptr</p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../interprocess/indexes_reference.html#doxygen.boost_interprocess_header_reference.shared__ptr_8hpp" title="Header &lt;boost/interprocess/smart_ptr/shared_ptr.hpp&gt;">boost/interprocess/smart_ptr/shared_ptr.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">typename</span> VoidAllocator<span class="special">,</span> <span class="keyword">typename</span> Deleter<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">T</span>                                                                                                 <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a522b966dd3890d2b15f1ff618827a4cc"></a><span class="identifier">element_type</span><span class="special">;</span>           
  <span class="keyword">typedef</span> <span class="identifier">T</span>                                                                                                 <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1ab3e545e3efc2421048122ef1ebaba48b"></a><span class="identifier">value_type</span><span class="special">;</span>             
  <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">container</span><span class="special">::</span><span class="identifier">allocator_traits</span><span class="special">&lt;</span> <span class="identifier">VoidAllocator</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">pointer</span>                                      <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a77761c521ab0eea267d16412df6fcc57"></a><span class="identifier">void_ptr</span><span class="special">;</span>               
  <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">pointer_traits</span><span class="special">&lt;</span> <span class="identifier">void_ptr</span> <span class="special">&gt;</span><span class="special">::</span><span class="keyword">template</span> <span class="identifier">rebind_pointer</span><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">type</span>                  <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a4384c0901d17f50f90979e0eace50600"></a><span class="identifier">pointer</span><span class="special">;</span>                
  <span class="keyword">typedef</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span>                                                                                       <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1af489744d5b7fa8360f3b798fb1f922fe"></a><span class="identifier">reference</span><span class="special">;</span>              
  <span class="keyword">typedef</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span>                                                                                       <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a1c625478f66575fc00378281c95af56b"></a><span class="identifier">const_reference</span><span class="special">;</span>        
  <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">pointer_traits</span><span class="special">&lt;</span> <span class="identifier">void_ptr</span> <span class="special">&gt;</span><span class="special">::</span><span class="keyword">template</span> <span class="identifier">rebind_pointer</span><span class="special">&lt;</span> <span class="identifier">constDeleter</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">type</span>       <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1ae10847a113dc50a0d624848ad0ad8703"></a><span class="identifier">const_deleter_pointer</span><span class="special">;</span>  
  <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">pointer_traits</span><span class="special">&lt;</span> <span class="identifier">void_ptr</span> <span class="special">&gt;</span><span class="special">::</span><span class="keyword">template</span> <span class="identifier">rebind_pointer</span><span class="special">&lt;</span> <span class="identifier">constVoidAllocator</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">type</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1ab9f39f2e0a5953b8bcaf0a1fa3e74267"></a><span class="identifier">const_allocator_pointer</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="../boost_container_header_reference/classboost_1_1container_1_1new__allocator_3_01void_01_4.html#id66-bb">public member functions</a></span>
  <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a9150799938dd3f9dc224fe054763e8ee"><span class="identifier">shared_ptr</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">explicit</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a7532cfda8a6045e6587297c19edae53c"><span class="identifier">shared_ptr</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pointer</span> <span class="special">&amp;</span><span class="special">,</span> 
                      <span class="keyword">const</span> <span class="identifier">VoidAllocator</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">VoidAllocator</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> 
                      <span class="keyword">const</span> <span class="identifier">Deleter</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">Deleter</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a264ca317d2ad4d6088542c6e9abce6f5"><span class="identifier">shared_ptr</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a56fffd7611b004859f4c6b0cae9dd2ca"><span class="identifier">shared_ptr</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">pointer</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Y<span class="special">&gt;</span> 
    <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a75f6d677baaf2fd33869fafe6ffa878e"><span class="identifier">shared_ptr</span></a><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">&lt;</span> <span class="identifier">Y</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Y<span class="special">&gt;</span> 
    <span class="keyword">explicit</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a2625cb1ddf4044f85edd00dcc9c94b8f"><span class="identifier">shared_ptr</span></a><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1weak__ptr.html" title="Class template weak_ptr">weak_ptr</a><span class="special">&lt;</span> <span class="identifier">Y</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">explicit</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a582f4eb88535f4d4a29adc4c90d9e994"><span class="identifier">shared_ptr</span></a><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Y<span class="special">&gt;</span> 
    <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1af7dc2decc7eda869ee42975fb258be35"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">&lt;</span> <span class="identifier">Y</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a6d6ca5630fc2df1e7ea804cf64037b06"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="identifier">BOOST_COPY_ASSIGN_REF</span><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a5872b285424dbfd70651d9f404f3d932"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a1e1ddcf08cc644fb9bafbb1ec7f5e67d"><span class="identifier">reset</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span> 
    <span class="keyword">void</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a94180a982830fbe620450271a750014e"><span class="identifier">reset</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Pointer</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">VoidAllocator</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">VoidAllocator</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> 
               <span class="keyword">const</span> <span class="identifier">Deleter</span> <span class="special">&amp;</span> <span class="special">=</span> <span class="identifier">Deleter</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Y<span class="special">&gt;</span> 
    <span class="keyword">void</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a430f25700cdc9ed88f04c2e881e49538"><span class="identifier">reset</span></a><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">&lt;</span> <span class="identifier">Y</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">,</span> 
               <span class="keyword">const</span> <span class="identifier">pointer</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">reference</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a3b5f5988f515f610054a95b0d3b33b28"><span class="keyword">operator</span><span class="special">*</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">pointer</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a92cda07048c91eb44a002269d6304e6c"><span class="keyword">operator</span><span class="special">-&gt;</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="identifier">pointer</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1afd7aa3cbdadd00f7e21f011438a4275a"><span class="identifier">get</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1aa608eca8c322bd678ebc365bedd214b2"><span class="keyword">operator</span><span class="special">!</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1ab90d9b6271161c6a72b7ec07668b0b5e"><span class="identifier">unique</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">long</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a8b5bf27c04529a61f95485c1a22f43b2"><span class="identifier">use_count</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a5a304307f05056f1c60a89aed533bff6"><span class="identifier">swap</span></a><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.17.19.3.51.5.4"></a><h2>Description</h2>
<p><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> stores a pointer to a dynamically allocated object. The object pointed to is guaranteed to be deleted when the last <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> pointing to it is destroyed or reset.</p>
<p><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> is parameterized on T (the type of the object pointed to), VoidAllocator (the void allocator to be used to allocate the auxiliary data) and Deleter (the deleter whose operator() will be used to delete the object.</p>
<p>The internal pointer will be of the same pointer type as typename VoidAllocator::pointer type (that is, if typename VoidAllocator::pointer is offset_ptr&lt;void&gt;, the internal pointer will be offset_ptr&lt;T&gt;).</p>
<p>Because the implementation uses reference counting, cycles of <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> instances will not be reclaimed. For example, if main() holds a <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> to A, which directly or indirectly holds a <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> back to A, A's use count will be 2. Destruction of the original <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> will leave A dangling with a use count of 1. Use <a class="link" href="classboost_1_1interprocess_1_1weak__ptr.html" title="Class template weak_ptr">weak_ptr</a> to "break cycles." </p>
<div class="refsect2">
<a name="id-1.3.17.19.3.51.5.4.6"></a><h3>
<a name="id66-bb"></a><code class="computeroutput">shared_ptr</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a9150799938dd3f9dc224fe054763e8ee"></a><span class="identifier">shared_ptr</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Constructs an empty <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a>. Use_count() == 0 &amp;&amp; <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1afd7aa3cbdadd00f7e21f011438a4275a">get()</a>== 0. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a7532cfda8a6045e6587297c19edae53c"></a><span class="identifier">shared_ptr</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">pointer</span> <span class="special">&amp;</span> p<span class="special">,</span> 
                    <span class="keyword">const</span> <span class="identifier">VoidAllocator</span> <span class="special">&amp;</span> a <span class="special">=</span> <span class="identifier">VoidAllocator</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> 
                    <span class="keyword">const</span> <span class="identifier">Deleter</span> <span class="special">&amp;</span> d <span class="special">=</span> <span class="identifier">Deleter</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>
<p>Constructs a <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> that owns the pointer p. Auxiliary data will be allocated with a copy of a and the object will be deleted with a copy of d. Requirements: Deleter and A's copy constructor must not throw. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a264ca317d2ad4d6088542c6e9abce6f5"></a><span class="identifier">shared_ptr</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span> r<span class="special">)</span><span class="special">;</span></pre>
<p>Copy constructs a <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a>. If r is empty, constructs an empty <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a>. Otherwise, constructs a <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> that shares ownership with r. Never throws. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a56fffd7611b004859f4c6b0cae9dd2ca"></a><span class="identifier">shared_ptr</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span> other<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">pointer</span> <span class="special">&amp;</span> p<span class="special">)</span><span class="special">;</span></pre>
<p>Constructs a <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> that shares ownership with other and stores p. Postconditions: <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1afd7aa3cbdadd00f7e21f011438a4275a">get()</a> == p &amp;&amp; <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a8b5bf27c04529a61f95485c1a22f43b2">use_count()</a> == r.use_count(). Throws: nothing. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Y<span class="special">&gt;</span> 
  <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a75f6d677baaf2fd33869fafe6ffa878e"></a><span class="identifier">shared_ptr</span><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">&lt;</span> <span class="identifier">Y</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span> r<span class="special">)</span><span class="special">;</span></pre>
<p>If r is empty, constructs an empty <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a>. Otherwise, constructs a <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> that shares ownership with r. Never throws. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Y<span class="special">&gt;</span> 
  <span class="keyword">explicit</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a2625cb1ddf4044f85edd00dcc9c94b8f"></a><span class="identifier">shared_ptr</span><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1weak__ptr.html" title="Class template weak_ptr">weak_ptr</a><span class="special">&lt;</span> <span class="identifier">Y</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span> r<span class="special">)</span><span class="special">;</span></pre>
<p>Constructs a <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> that shares ownership with r and stores a copy of the pointer stored in r. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a582f4eb88535f4d4a29adc4c90d9e994"></a><span class="identifier">shared_ptr</span><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
<p>Move-Constructs a <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> that takes ownership of other resource and other is put in default-constructed state. Throws: nothing. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Y<span class="special">&gt;</span> 
  <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1af7dc2decc7eda869ee42975fb258be35"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">&lt;</span> <span class="identifier">Y</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span> r<span class="special">)</span><span class="special">;</span></pre>
<p>Equivalent to shared_ptr(r).swap(*this). Never throws </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a6d6ca5630fc2df1e7ea804cf64037b06"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="identifier">BOOST_COPY_ASSIGN_REF</span><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">)</span> r<span class="special">)</span><span class="special">;</span></pre>
<p>Equivalent to shared_ptr(r).swap(*this). Never throws </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a5872b285424dbfd70651d9f404f3d932"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> <span class="special">&amp;&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
<p>Move-assignment. Equivalent to shared_ptr(other).swap(*this). Never throws </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a1e1ddcf08cc644fb9bafbb1ec7f5e67d"></a><span class="identifier">reset</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>This is equivalent to: this_type().swap(*this); </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Pointer<span class="special">&gt;</span> 
  <span class="keyword">void</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a94180a982830fbe620450271a750014e"></a><span class="identifier">reset</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Pointer</span> <span class="special">&amp;</span> p<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">VoidAllocator</span> <span class="special">&amp;</span> a <span class="special">=</span> <span class="identifier">VoidAllocator</span><span class="special">(</span><span class="special">)</span><span class="special">,</span> 
             <span class="keyword">const</span> <span class="identifier">Deleter</span> <span class="special">&amp;</span> d <span class="special">=</span> <span class="identifier">Deleter</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>
<p>This is equivalent to: this_type(p, a, d).swap(*this); </p>
</li>
<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Y<span class="special">&gt;</span> 
  <span class="keyword">void</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a430f25700cdc9ed88f04c2e881e49538"></a><span class="identifier">reset</span><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">&lt;</span> <span class="identifier">Y</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="keyword">const</span> <span class="special">&amp;</span> r<span class="special">,</span> 
             <span class="keyword">const</span> <span class="identifier">pointer</span> <span class="special">&amp;</span> p<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">reference</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a3b5f5988f515f610054a95b0d3b33b28"></a><span class="keyword">operator</span><span class="special">*</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Returns a reference to the pointed type </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">pointer</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a92cda07048c91eb44a002269d6304e6c"></a><span class="keyword">operator</span><span class="special">-&gt;</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Returns the pointer pointing to the owned object </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">pointer</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1afd7aa3cbdadd00f7e21f011438a4275a"></a><span class="identifier">get</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Returns the pointer pointing to the owned object </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1aa608eca8c322bd678ebc365bedd214b2"></a><span class="keyword">operator</span><span class="special">!</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Not operator. Returns true if this-&gt;<a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1afd7aa3cbdadd00f7e21f011438a4275a">get()</a> != 0, false otherwise </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1ab90d9b6271161c6a72b7ec07668b0b5e"></a><span class="identifier">unique</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Returns <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a8b5bf27c04529a61f95485c1a22f43b2">use_count()</a> == 1. <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1ab90d9b6271161c6a72b7ec07668b0b5e">unique()</a> might be faster than <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a8b5bf27c04529a61f95485c1a22f43b2">use_count()</a> </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">long</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a8b5bf27c04529a61f95485c1a22f43b2"></a><span class="identifier">use_count</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Returns the number of <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a> objects, *this included, that share ownership with *this, or an unspecified nonnegative value when *this is empty. <a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a8b5bf27c04529a61f95485c1a22f43b2">use_count()</a> is not necessarily efficient. Use only for debugging and testing purposes, not for production code. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1shared__ptr_1a5a304307f05056f1c60a89aed533bff6"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="classboost_1_1interprocess_1_1shared__ptr.html" title="Class template shared_ptr">shared_ptr</a><span class="special">&lt;</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">VoidAllocator</span><span class="special">,</span> <span class="identifier">Deleter</span> <span class="special">&gt;</span> <span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
<p>Exchanges the contents of the two smart pointers. </p>
</li>
</ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2005-2024 Ion Gaztanaga<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="structboost_1_1interprocess_1_1managed__shared__ptr.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../interprocess/indexes_reference.html#doxygen.boost_interprocess_header_reference.shared__ptr_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="shared__ptr_8hpp_1a946d9135de9f10bec397e4972c3160ac.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
